/*
 * Copyright (c) 2006-2019, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2019-10-26     ChenYong     first version
 */

#ifndef __BOARD_H__
#define __BOARD_H__

#include <rtthread.h>
#include <stm32f0xx.h>
#include "drv_common.h"

#ifdef __cplusplus
extern "C" {
#endif

/*-------------------------- UART CONFIG BEGIN --------------------------*/

/** Once the corresponding UART is configured, it can be used as a console or other purposes.
  *
  * STEP 1, define macro define related to the serial port opening based on the serial port number
  *                 such as     #define BSP_USING_UATR1
  *
  * STEP 2, according to the corresponding pin of serial port, write the related serial port information
  *                 such as     #define UART1_TX_PORT   GPIOA
  *                             #define UART1_RX_PORT   GPIOA
  *                             #define UART1_TX_PIN    GPIO_PIN_9
  *                             #define UART1_RX_PIN    GPIO_PIN_10
  *
  * Attention: 1. Nano project haven't support DMA, if you want use DMA unless you configure it by yourself.
  *            2. When at latest one serial port is configured, the last serial port will be as console. You can
  *            rewrite rt_hw_usart_init function to realize your logic.
  *
  *
  */

#define VERSION_FILE      "version.info"
#define UPDATE_FILE       "update.bin"
#define UPDATE_TEMP_FILE  "update.temp"
#define VERSION           1L              /**< major version number */
#define SUBVERSION        0L              /**< minor version number */
#define REVISION          1L              /**< revise version number */
#define APP_START_ADDR    0x0800C000
#define DEVICE_TYPE       0x00002333
/*-------------------------- UART CONFIG END --------------------------*/

/*-------------------------- ROM/RAM CONFIG BEGIN --------------------------*/

#define STM32_FLASH_START_ADRESS       ((uint32_t)0x8000000)
#define STM32_FLASH_SIZE               (256)
#define STM32_FLASH_END_ADDRESS        ((uint32_t)(STM32_FLASH_START_ADRESS + STM32_FLASH_SIZE * 1024))

#define STM32_SRAM1_SIZE               (32)
#define STM32_SRAM1_START              (0x20000000)
#define STM32_SRAM1_END                (STM32_SRAM1_START + STM32_SRAM1_SIZE * 1024)

#if defined(__CC_ARM) || defined(__CLANG_ARM)
extern int Image$RW_IRAM1$ZI$Limit;
#define HEAP_BEGIN      ((void *)&Image$RW_IRAM1$ZI$Limit)
#elif __ICCARM__
#pragma section="CSTACK"
#define HEAP_BEGIN      (__segment_end("CSTACK"))
#else
extern int __bss_end;
#define HEAP_BEGIN      (((void *)&__bss_end)+0x400)
#endif

#define HEAP_END        STM32_SRAM1_END

/*-------------------------- ROM/RAM CONFIG END --------------------------*/

void SystemClock_Config(void);

#ifdef __cplusplus
}
#endif

#endif /* __BOARD_H__ */

